package com.powerhua.oa.assistant.meeting;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.powerhua.core.bean.BeansRegisterLocator;
import com.powerhua.core.web.IServletAction;

public class MeetingRoomAction implements IServletAction {
	
	private static final Log LOG = LogFactory.getLog(MeetingRoomAction.class);

	@Override
	public String doAction(HttpServletRequest request) {
		String result = "";
		
		String action = request.getParameter("action");
		MeetingRoomManager mgr = (MeetingRoomManager)BeansRegisterLocator.getBean("meetingRoomManager");
		if("select".equals(action)) {
			Date date = new Date(System.currentTimeMillis());
			String d = request.getParameter("date_");
			if(d != null && !"".equals(d)) {
				try {
					date = new SimpleDateFormat("yyyy-MM-dd").parse(d);
				} catch (ParseException e) {
					LOG.error("日期错误", e);
				}
			}
			result += mgr.listMeetingRoomSelector(date);		
		}
		
		return result;
	}

}
